<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

define('NAME','hzwyyx');
define('PASSWORD','tanliuliu166');
define('HOST','http://210.51.190.19:8080/eums/send_strong.do');

/**
 * 由空间畅想短信服务商提供(北京空间畅想信息技术有限责任公司)
 * 自定义-短信类
 */
class My_spacei{
    function __construct() {}
    
    function sendSMS($mobile,$content){
        $postData = array();
        $postData['name'] = NAME;
        $postData['seed'] = date("YmdHis");
        $postData['key'] = strtolower(md5(md5(PASSWORD).$postData['seed']));
        $postData['dest'] = $mobile;
        $postData['content'] = $content;
        $postData['ext'] = "";
        $result = $this->curl_post(HOST,$postData);
        return $result;
    }
    
    private function curl_post($url,$postData){
        foreach ($postData as $k => $v )
        {
            $o .= "$k=" . urlencode ( $v ) . "&" ;
        }
        $post_data = substr ( $o , 0 ,- 1 ) ;
        $curl = curl_init();
        // 设置你需要抓取的URL
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl , CURLOPT_POSTFIELDS , $post_data) ;
        // 设置cURL 参数，要求结果保存到字符串中还是输出到屏幕上。
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

        curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
        curl_setopt($curl, CURLOPT_TIMEOUT, 30);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
        curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); 
        // 运行cURL，请求网页
        $data = curl_exec($curl);
        $http_code = curl_getinfo($curl,CURLINFO_HTTP_CODE);
        // 关闭URL请求
        curl_close($curl);
        if($http_code == 200){
            return $data;
        }
    }
}
